﻿#include "CardSetViewModel.h"

#include "CardViewModel.h"

using namespace Views::Models::Network;

CardSetViewModel::CardSetViewModel(Cards::CardsCollection cards)
	: cards(cards)
{
}

CardSetViewModel::CardSetViewModel(Cards::CardSet card_set)
	: card_set(card_set)
{
}

sf::Packet& Views::Models::Network::operator <<(sf::Packet& Packet, const CardSetViewModel& model)
{
	Packet << sf::Uint8(model.card_set.size());
	for(Cards::CardSet::Iterator i = model.card_set.begin(); i != model.card_set.end(); ++i)
	{
		CardViewModel cvm(*i);
		Packet << cvm;
	}
	return Packet;
}

sf::Packet& Views::Models::Network::operator >>(sf::Packet& Packet, CardSetViewModel& model)
{
	model.card_set = Cards::CardSet();
	sf::Uint8 size;
	Packet >> size;
	CardViewModel cvm(model.cards);
	for(int i = 0; i < size; ++i)
	{
		Packet >> cvm;
		model.card_set.add(cvm.card);
	}
	return Packet;
}

